import CryptoJS from 'crypto-js'

// 密码登录加密
export default {
    encrypt: function (data) {
    /* AES前端加密 */
        let key = CryptoJS.enc.Utf8.parse('1Dd2Bb3Cc4Aa5Ee0')
        let iv = CryptoJS.enc.Utf8.parse('1Dd2Bb3Cc4Aa5Ee0')
        let str = CryptoJS.AES.encrypt(data, key, {iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.ZeroPadding}).toString()
        return this.filter(str)
    },
    filter: function (value) {
        value = value.replace('#', '%23')
            .replace('%', '%25')
            .replace('&', '%26')
            .replace('+', '%2B')
            .replace('//', '%2F')
            .replace('?', '%3F')
        return value
    }
}
